package com.example.jetpack04.viewmodel;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

public class ScoreViewModel extends ViewModel {

    private MutableLiveData<Integer> lscore ;

    private MutableLiveData<Integer> rscore ;

    private int pre_lscore ;

    private int pre_rscore ;

    public ScoreViewModel() {
        if (lscore == null || rscore == null ){
            lscore  = new MutableLiveData<>(0);
            rscore =new MutableLiveData<>(0);
            pre_lscore = 0 ;
            pre_rscore = 0 ;
        }
    }

    public MutableLiveData<Integer> getLscore() {
        return lscore;
    }

    public void setLscore(MutableLiveData<Integer> lscore) {
        this.lscore = lscore;
    }

    public MutableLiveData<Integer> getRscore() {
        return rscore;
    }

    public void setRscore(MutableLiveData<Integer> rscore) {
        this.rscore = rscore;
    }


    public void ladd(int i){
        pre_lscore = lscore.getValue();
        lscore.setValue(lscore.getValue()+i);

    }

    public void radd(int i){
        pre_rscore = rscore.getValue();
        rscore.setValue(rscore.getValue()+i);
    }

    public void reset(){
        lscore.setValue(0);
        rscore.setValue(0);
    }


    public void back(){
        lscore.setValue(pre_lscore);
        rscore.setValue(pre_rscore);
    }
}
